﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Web;
using System.Text;
using dis.sys.hw1.Contract;
using dis.sys.hw1.Model;

namespace dis.sys.hw1.ClientProxy
{
    public class HotelSearchProxy : ClientBase<ISearchService>, ISearchService
    {
        public HotelSearchProxy(string baseAddress)
            :base(new WebHttpBinding(), new EndpointAddress(baseAddress))
        {
            this.Endpoint.Behaviors.Add(new WebHttpBehavior());
        }

        public bool IsUp()
        {
            try
            {
                return Channel.IsUp();
            }
            catch (Exception)
            {
                return false;
            }
        }

        public IList<Hotel> Search(long fromDateTicks, long toDateTicks, double minStars, double minRating)
        {
            return Channel.Search(fromDateTicks, toDateTicks, minStars, minRating);
        }

        //UnUsed
        public IDictionary<Tuple<long, long, double, double>, Tuple<DateTime, IList<Hotel>>> QueryCache
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #region oldinterface
        //public int Book(long fromDateTicks, long toDateTicks, int roomNumber, string hotelName)
        //{
        //    return Channel.Book(fromDateTicks, toDateTicks, roomNumber, hotelName);
        //}

        //public bool Cancel(int bookingId, string hotelName)
        //{
        //    return Channel.Cancel(bookingId, hotelName);
        //}
        #endregion
    }
}
